var cc__decorate = __decorate;
var cc__awaiter = __awaiter;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2ChangeMaterial = require("ChangeMaterial");
var $2GameUser = require("GameUser");
var $2EventCenter = require("EventCenter");
var $2EventDefine = require("EventDefine");
var $2UIManager = require("UIManager");
var $2PlatformMgr = require("PlatformMgr");
var $2ccUtil = require("ccUtil");
var $2UIHelp = require("UIHelp");
var $2BaseUIPopup = require("BaseUIPopup");
var $2UIVMain = require("UIVMain");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_UIAddDesk = /* */function (_g$default) {
  function _ctor() {
    var _this93;
    babel_classCallCheck(this, _ctor);
    _this93 = _callSuper(this, _ctor, arguments);
    _this93.closeBtn = null;
    _this93.enterBtn = null;
    _this93.receiveBtn = null;
    _this93.receivedLbl = null;
    _this93.isDesktopEnter = false;
    return _this93;
  }
  babel_inherits(_ctor, _g$default);
  return babel_createClass(_ctor, [{
    key: "setData",
    value: function setData(e) {
      if (false === $2GameUser.default.getInstance().getAddDesktopState()) {
        this.syncAddDesktopView();
      } else {
        this.isDesktopEnter = e;
        if (this.isDesktopEnter) {
          this.syncAddDesktopView();
        } else {
          this.receiveBtn.active = false, this.receivedLbl.active = false, this.enterBtn.active = false, $2GameUser.default.getInstance().getDesktopDailyRewardClaimState() ? this.receivedLbl.active = true : (this.receiveBtn.active = true, this.receiveBtn.getComponent($2ChangeMaterial.default).setItemSprite($2ChangeMaterial.eMaterialType.Gray));
        }
      }
    }
  }, {
    key: "onClose",
    value: function onClose() {
      this.close();
    }
  }, {
    key: "onEnter",
    value: function onEnter() {
      var _this94 = this;
      $2PlatformMgr.default.Instance().addShortcut(function (e) {
        if (e) {
          $2GameUser.default.getInstance().setAddDesktopState(true);
          _this94.isDesktopEnter = true;
          _this94.syncAddDesktopView();
        }
      });
    }
  }, {
    key: "receiveDesktopRewards",
    value: function receiveDesktopRewards() {
      return cc__awaiter(this, undefined, undefined, /* */babel_regeneratorRuntime().mark(function _callee4() {
        return babel_regeneratorRuntime().wrap(function _callee4$(_context5) {
          while (1) {
            switch (_context5.prev = _context5.next) {
              case 0:
                $2GameUser.default.getInstance().tili++;
                _context5.next = 3;
                return $2ccUtil.default.goldFlyEffect();
              case 3:
                $2EventCenter.default.postEvent($2EventDefine.default.GAME_TILI_INFO_UPDATE);
                $2UIHelp.UIHelp.showTip("恭喜获取1点体力");
                $2GameUser.default.getInstance().setDesktopDailyRewardClaimState(true);
                this.syncAddDesktopView();
                $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).syncDesktopBtnState();
                this.close();
              case 9:
              case "end":
                return _context5.stop();
            }
          }
        }, _callee4, this);
      }));
    }
  }, {
    key: "onReceive",
    value: function onReceive() {
      if (this.isDesktopEnter) {
        this.receiveDesktopRewards();
      } else {
        $2UIHelp.UIHelp.showTip("请从桌面入口进入领取奖励");
      }
    }
  }, {
    key: "syncAddDesktopView",
    value: function syncAddDesktopView() {
      this.receiveBtn.active = false;
      this.receivedLbl.active = false;
      this.enterBtn.active = false;
      if ($2GameUser.default.getInstance().getAddDesktopState()) {
        this.enterBtn.active = false;
        if ($2GameUser.default.getInstance().getDesktopDailyRewardClaimState()) {
          this.receivedLbl.active = true;
        } else {
          this.receiveBtn.active = true;
        }
      } else {
        this.enterBtn.active = true;
      }
    }
  }, {
    key: "onEnable",
    value: function onEnable() {
      babel_get(babel_getPrototypeOf(_ctor.prototype), "onEnable", this).call(this);
      this.closeBtn.on("click", this.onClose, this);
      this.enterBtn.on("click", this.onEnter, this);
      this.receiveBtn.on("click", this.onReceive, this);
    }
  }, {
    key: "onDisable",
    value: function onDisable() {
      babel_get(babel_getPrototypeOf(_ctor.prototype), "onDisable", this).call(this);
      this.closeBtn.off("click", this.onClose, this);
      this.enterBtn.off("click", this.onEnter, this);
      this.receiveBtn.off("click", this.onReceive, this);
    }
  }]);
}($2BaseUIPopup.default);
def_UIAddDesk.className = "UIAddDesk";
cc__decorate([ccp_property(cc.Node)], def_UIAddDesk.prototype, "closeBtn", undefined);
cc__decorate([ccp_property(cc.Node)], def_UIAddDesk.prototype, "enterBtn", undefined);
cc__decorate([ccp_property(cc.Node)], def_UIAddDesk.prototype, "receiveBtn", undefined);
cc__decorate([ccp_property(cc.Node)], def_UIAddDesk.prototype, "receivedLbl", undefined);
def_UIAddDesk = cc__decorate([ccp_ccclass], def_UIAddDesk);
exports.default = def_UIAddDesk;